package br.fatec.ads.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.fatec.ads.dao.ProcessoSeletivoDAO;
import br.fatec.ads.dao.VagaPerguntaDAO;
import br.fatec.ads.exception.DataBaseException;
import br.fatec.ads.exception.ProcessoSeletivoException;
import br.fatec.ads.exception.VagaPerguntaException;
import br.fatec.ads.model.ProcessoSeletivo;
import br.fatec.ads.model.VagaPergunta;

public class VagaPerguntaExcluir extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public VagaPerguntaExcluir() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			HttpSession session = request.getSession(false);
			
			VagaPergunta vagaPergunta = new VagaPergunta();
			
			vagaPergunta.setIdVagaPergunta(Integer.parseInt(request.getParameter("idVagaPerguntaExcluir")));
			vagaPergunta.setUsuario(session.getAttribute("usuarioDesc").toString());
			
			VagaPerguntaDAO vagaPerguntaDAO = new VagaPerguntaDAO();
		
			vagaPerguntaDAO.excluirVagaPergunta(vagaPergunta);
			
			request.getRequestDispatcher("VagaPerguntaPesquisar?acao=SUCESSO_EXCLUIR").forward(request, response);
		} catch (VagaPerguntaException e) {
			request.getRequestDispatcher("VagaPerguntaPesquisar?acao=ERRO_EXCLUIR").forward(request, response);
			e.printStackTrace();
		} catch (DataBaseException e) {
			request.getRequestDispatcher("VagaPerguntaPesquisar?acao=ERRO_EXCLUIR").forward(request, response);
			e.printStackTrace();
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}
}